# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=glade
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.36.0
pkgrel=1
pkgdesc="User interface builder for GTK+ and GNOME (mingw-w64)"
arch=('any')
url="https://glade.gnome.org/"
license=("GPL" "LGPL")
options=('strip' '!debug' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-python-gobject"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-gnome-common"
             "intltool"
             "itstool")
optdepends=("${MINGW_PACKAGE_PREFIX}-python: Python widgets support"
            #'devhelp: help browser'
            )
install=glade-${CARCH}.install
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        0001-Fix-windres-invocation.mingw.patch
        0005-give-gtk-cflags-to-gir.patch
        0006-disable-gnome-help.patch
        0007-glade-3.16.1-no-undefined.patch)
sha256sums=('19b546b527cc46213ccfc8022d49ec57e618fe2caa9aa51db2d2862233ea6f08'
            'cec3e7ad59ff17313eb8c33912a8df67427c77562864cafdd4b4cc82c17aef63'
            '0e46e53437b444e64ed83d4ac2e70c73cb4ea3ca7669f5932d201e10ce0d58a7'
            '636ead9163a1a23cf7fc8144cf99de94db55c4bc97c0def2fed670bd4ec7900d'
            'bf90d055a7bdd99599ebea9c610eb56850e0dd976532d543787f64a136d35939')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-Fix-windres-invocation.mingw.patch
  patch -p1 -i ${srcdir}/0005-give-gtk-cflags-to-gir.patch
  patch -p1 -i ${srcdir}/0006-disable-gnome-help.patch
  patch -p1 -i ${srcdir}/0007-glade-3.16.1-no-undefined.patch

  autoreconf -fi
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  PYTHON=${MINGW_PREFIX}/bin/python \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-introspection \
    --enable-shared \
    --disable-gtk-doc \
    --enable-gladeui \
    --disable-man-pages

  make VERBOSE=1
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
}
